package com.demo.service;

import com.demo.entity.Dept;
import com.demo.mapper.DeptMapper;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Data
@Service //告诉扫描包的时候，我愿意被接管
public class DeptServiceImpl implements DeptService {
    @Autowired
    private DeptMapper deptMapper;

    @Override
    public List<Dept> selectAllDept() {
        return deptMapper.selectAllDept();
    }

    @Override

    public Dept selectDeptById(int id) {
        return deptMapper.selectDeptById(id);
    }

    @Override

    public boolean deleteDeptById(int id) {
        //mapper的delete、update、insert返回值是int
        //service的delete、update、insert返回值是boolean
        // 受影响行数大于0，就是成功，返回true,否则false
        return deptMapper.deleteDeptById(id) > 0;
    }

    @Override

    public boolean insertDept(Dept dept) {
        return deptMapper.insertDept(dept) > 0;
    }

    @Override

    public boolean updateDept(Dept dept) {
        return deptMapper.updateDept(dept) > 0;
    }
}
